package com.sdwl.brcl.util;

/**
 * @author niunafei
 * @function
 * @email niunafei0315@163.com
 * @date 2019/6/28  下午2:02
 */
public enum ApiHttpCode {
    /**响应成功*/
    SUCCESS(200, "OK"),
    /**服务器异常*/
    ERROR(500, "ERROR"),
    /**参数或语法不对*/
    BAD_REQUEST(400, "参数或者语法不对"),
    /**请求资源不存在*/
    NOT_FOUND(404, "请求的资源不存在"),
    /**未授权访问*/
    UNAUTHORIZED(401, "访问未授权"),

    SUCCESS_TWO_HUNDRED(200, "ok"),

    DONT_REPEAT(401, "访问频繁,请稍后重试"),

    ENTITY_DATA(404, "请求资源不存在！"),

    SERIOUS(500, "系统内部错误"),

    LOGINFAIL(600, "登录失败"),

    UNLOGIN(601, "请登录"),

    UNSUPPORT(701, "业务不支持"),

    UPDATED_DATE_EXPPIRED(800, "更新数据已经失效"),

    UPDATED_DATA_FAILED(801, "更新数据失败"),

    UNIVERSAL(705, "操作失败"),

    NULL_USERNAME(301, "用户名不能为空"),

    NULL_PWD(301, "密码不能为空"),

    NULL_MOBILE(301, "手机号不能为空"),

    MOBILE_FORMAT(301, "手机号格式错误"),

    PWD_FORMAT(-1, "密码必须为数字加字母,且长度在6位以上"),

    NULL_MOBILE_CODE(301, "手机验证码不能为空"),

    UPDATE_ERROR(301,"修改失败"),

    GAO_DE_API_RESULT_ERROR(-1,"高德API-Result错误！"),

    SIGN_IN_ERROR(-1,"超出签到距离！"),

    SIGN_IN_UNAUTHZ_ERROR(-1,"设置项目距签到失败，没有权限！"),

    SIGN_IN_NULL_ERROR(-1,"该项目暂未设置签到点！"),

    UPDATE_SUCCESS(0,"修改成功"),
    EX_ARITHMETICEXCEPTION(70001, "数字运算错误"),
    EX_NULLPOINTEREXCEPTION(70002, "有数据存在空值"),
    EX_CLASSCASTEXCEPTION(70003, "类型强制转换异常"),
    EX_ARRAYINDEXOUTOFBOUNDSEXCEPTION(70004, "数组下标越界"),
    EX_IOEXCEPTION(70005, "输入输出异常"),
    EX_CLASSCIRCULARITYERROR(70006, "循环依赖错误"),
    EX_NUMBERFORMATEXCEPTION(70007, "格式转换错误"),
    EX_SQLEXCEPTION(70008, "数据库出了点小差错"),
    EX_INDEXOUTOFBOUNDSEXCEPTION(70009, "索引越界"),
    EX_STRINGINDEXOUTOFBOUNDSEXCEPTION(70010, "字符串索引越界"),
    EX_DataIntegrityViolationException(70012, "输入字段长度过长"),
    EX_HTTPHOSTCONNECTEXCEPTION(70011, "第三方接口超时"),
    EX_OFFICEXMLFILEEXCEPTION(70013, "导入的文件类型不准确,请修复后重试"),
    EX_ERROR(77777, "系统出了点小差错,请稍后再试!"),
    EX_CONNECT_TIMEOUT_Exception(70014,"请求外部链接超时"),
    EX_CHECK_ARGS(100001, "参数异常"),

    UNAUTHZ(802, "无操作权限");


    private int code;
    private String desc;

    ApiHttpCode(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public int getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public static ApiHttpCode valueOf(int value) {
        for (ApiHttpCode role : ApiHttpCode.values()) {
            if (role.code == value) {
                return role;
            }
        }
        return null;
    }
}
